package com.dominator.repository;

import com.dominFramework.core.dao.SqlDao;
import com.dominFramework.core.typewrap.Dto;
import com.dominFramework.core.typewrap.Dtos;
import com.dominFramework.core.utils.SystemUtils;
import com.dominator.mybatis.dao.T_game_orderDao;
import com.dominator.mybatis.dao.T_game_orderPO;
import com.dominator.socket.ApplicationContextRegister;
import com.dominator.socket.SocketService;
import com.dominator.utils.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public class DaoGameOrder {


    @Autowired
    T_game_orderDao game_orderDao;

    @Autowired
    SqlDao sqlDao;


    /**
     * 根据用户id查询订单,分页
     *
     * @param dto
     * @return
     */
    public Dto getOrderByDtoPage(Dto dto) throws ApiException {
        Dto newDto = Dtos.newDto();
        if (SystemUtils.isEmpty(dto.getPageLimit())) {
            dto.setPageLimit(10);
        }
        if (SystemUtils.isEmpty(dto.getPageStart())) {
            dto.setPageStart(0);
        }
        List<Dto> list = sqlDao.list("GameOrder.selectByUserIdPage", dto);
        newDto.put("datas", list);
        newDto.put("pageLimit", dto.getPageLimit());
        newDto.put("pageStart", dto.getPageStart());
        newDto.put("pageTotal", dto.getPageTotal());
        return newDto;
    }


    /**
     * 查询未完成订单
     * @return
     */
    public  List<T_game_orderPO> getUnFillingOrder(Dto dto){
        List<T_game_orderPO> list =sqlDao.list("GameOrder.getUnFillingOrder", dto);
        return list ;
    }




}
